package com.qianxx.base.utils;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;

public class PackageUtils {

	/**
	 * 获取应用版本号
	 */
	public static String getVersionName(Context context) {
		PackageManager pm = context.getPackageManager();
		String versionName = "1.0";
		try {
			PackageInfo info = pm.getPackageInfo(context.getPackageName(),
					PackageManager.GET_CONFIGURATIONS);
			versionName = info.versionName;
		} catch (NameNotFoundException e1) {
			e1.printStackTrace();
		}
		return versionName;
	}
}
